<?php 
class ExpressAction extends AdminPublicAction{
	/** =============
	 列表
	 =================**/
	public function index()
	{
		if((isset($_GET['sort'] ) && !empty($_GET['sort'])) && (isset($_GET['updown'] ) && !empty($_GET['updown']))){
			$sort   = I('sort');
			$upDown = I('updown');
		}else{
			$_GET['sort'] = $sort = "express_id";
			$_GET['updown'] = $upDown = "asc";
	
		}
		//echo $sort.$upDown;die;
		$keyword = I('keyword','');
	
		if(tep_not_null($keyword))$where['c.express_name']  = array('like','%'.$keyword.'%');
		
		//$where['c.express_status']=1;
		import("ORG.Util.Page");
		$page = 10;
		$count = D('ExpressView')->where($where)->count();
		$Page = new Page($count, $page);
		$list   = D('ExpressView')->getAll($where,$Page->firstRow. ',' . $Page->listRows,$sort.' '.$upDown);
		$show = $Page->show();
		//var_dump($list);die;
			
		if (S("success") != "")
		{
			$this->assign("msg", '<div class="success">'.S("success").'</div>');
			S('success',NULL);
		}
		if (S("err") != "")
		{
			$this->assign("msg", '<div class="err">'.S("err").'</div>');
			S('err',NULL);
		}
		$this->keyword = $keyword;
		$this->listing = $list;
		$this->page = $show;
		$this->left_express = 'current';
		$this->display();
	
	}

	
	public function changeStatus(){
		$check = M("express")->where(array("express_id" => (int)$_GET['id']))->getField('express_status');
		$news_status = ($check == 1)?0:1;
		M("express")->where(array("express_id" => (int)$_GET['id']))->setField('express_status',$news_status);
		echo (int)$news_status;
			
	}
}
?>